﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Housing;

public partial class ManageCenter_ManageChange : System.Web.UI.Page
{
    SubsidyRecord subsidy = new SubsidyRecord();
    KindRecord kind = new KindRecord();
    ReduceRecord reduce = new ReduceRecord();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["id"] != null && Request["noid"]!=null)
        {
            PageBind();
        }
        else
            WebHelper.AlertAndClose("链接地址错误！");

    }
    protected void PageBind()
    {
        int adjid = Convert.ToInt32(Request.QueryString["id"].ToString());
        string noid = Request.QueryString["noid"].ToString();
        if (Request.QueryString["type"].ToString() == "sub")
        {
            panlesub.Visible=true;
            subsidy.GetNewestSubsidyRecordByNoid(noid);
            if (subsidy.Adj_checked != "")
            {
                lblsubmoney.Text = subsidy.Adj_nowmoney;
                lblsubarea.Text = subsidy.Adj_nowarea;
            }
            subsidy.GetSubsidyRecordById(adjid);
            if(subsidy.Adj_checked!="")
            {

                lblsubnowarea.Text = subsidy.Adj_nowarea;
                lblsubnowmoney.Text = subsidy.Adj_nowmoney;
                lblsubremark.Text = subsidy.Adj_remark;
                lblsubreason.Text = subsidy.Adj_reason;
            }
        }
        else if (Request.QueryString["type"].ToString() == "red")
        {
            panlered.Visible = true;
            reduce.GetNewestReduceRecordBynoid(noid);
            if (reduce.Adj_checked != "")
            {
                lblcheckarea.Text = reduce.Adj_nowarea;
                lblmonthmoney.Text = reduce.Adj_nowmoney;
                lblreducemoney.Text = reduce.Adj_nowreduce;
            }
            reduce.GetReduceRecordById(adjid);
            if (reduce.Adj_checked != "")
            {
                lblnowcheckarea.Text = reduce.Adj_nowarea;
                lblnowmonthmoney.Text = reduce.Adj_nowmoney;
                lblnowredmoney.Text = reduce.Adj_nowreduce;
                lblredreason.Text = reduce.Adj_reason;
                lblredremark.Text = reduce.Adj_remark;
            }
        }
        else if (Request.QueryString["type"].ToString() == "kind")
        {
            panlekind.Visible = true;
            kind.GetNewestKindRecordBynoid(noid);
            if (kind.Adj_checked != "")
            {
                lblkindarea.Text = kind.Adj_nowarea;
                lblkindusearea.Text = kind.Adj_nowuserarea;
            }
            kind.GetKindRecordById(adjid);
            if (kind.Adj_checked != "")
            {
                lblnowkindarea.Text = kind.Adj_nowarea;
                lblnowusearea.Text = kind.Adj_nowuserarea;
                lblkindremark.Text = kind.Adj_remark;
                lblkindreason.Text = kind.Adj_reason;
            }
        }
        else
            WebHelper.AlertAndClose("无调整申请，关闭此页！");
    }
    protected void btnredpass_Click(object sender, EventArgs e)
    {
        bool succ = reduce.SetReduceChangePass(Request.QueryString["longid"].ToString(),Convert.ToInt32(Request.QueryString["id"].ToString()));
        if (succ)
            WebHelper.AlertAndCloseThenRefreshLastPage("审核通过，关闭当前页！");
        else
            WebHelper.AlertAndClose("操作失败，请重新操作");
    }
    protected void btnredunpass_Click(object sender, EventArgs e)
    {
        bool succ = reduce.SetReduceChangeUnPass(Convert.ToInt32(Request.QueryString["id"].ToString()));
        if (succ)
            WebHelper.AlertAndCloseThenRefreshLastPage("否决申请成功，关闭当前页!");
        else
            WebHelper.AlertAndClose("操作失败，请重新操作");
    }
    protected void btnkindpass_Click(object sender, EventArgs e)
    {
        bool succ = kind.SetKindChangePass(Request.QueryString["longid"].ToString(), Convert.ToInt32(Request.QueryString["id"].ToString()));
        if (succ)
            WebHelper.AlertAndCloseThenRefreshLastPage("审核通过，关闭当前页！");
        else
            WebHelper.AlertAndClose("操作失败，请重新操作");
    }
    protected void btnkindunpass_Click(object sender, EventArgs e)
    {
        bool succ = kind.SetKindChangeUnPass(Convert.ToInt32(Request.QueryString["id"].ToString()));
        if (succ)
            WebHelper.AlertAndCloseThenRefreshLastPage("否决申请成功，关闭当前页!");
        else
            WebHelper.AlertAndClose("操作失败，请重新操作");
    }
    protected void btnsubpass_Click(object sender, EventArgs e)
    {
        bool succ = subsidy.SetSubsidyChangePass(Request.QueryString["longid"].ToString(),Convert.ToInt32(Request.QueryString["id"].ToString()));
        if (succ)
            WebHelper.AlertAndCloseThenRefreshLastPage("审核通过，关闭当前页！");
        else
            WebHelper.AlertAndClose("操作失败，请重新操作");
    }
    protected void btnsubunpass_Click(object sender, EventArgs e)
    {
        bool succ = subsidy.SetSubsidyChangeUnPass(Convert.ToInt32(Request.QueryString["id"].ToString()));
        if (succ)
            WebHelper.AlertAndCloseThenRefreshLastPage("否决申请成功，关闭当前页!");
        else
            WebHelper.AlertAndClose("操作失败，请重新操作");
    }
}
